
import os
import sys
import datetime


format='%(asctime)s - %(levelname)s: %(message)s'

def debug(msg,*args,**kvargs): 
    msg = msg%(args)
    print >>sys.stdout,format%{"asctime":datetime.datetime.today(),"levelname":"DEBUG","message":msg}

def info(msg,*args,**kvargs):
    msg = msg%(args)
    print >>sys.stdout,format%{"asctime":datetime.datetime.today(),"levelname":"INFO","message":msg}

def warning(msg,*args,**kvargs):
    msg = msg%(args)
    print >>sys.stderr,format%{"asctime":datetime.datetime.today(),"levelname":"WARNING","message":msg} 

def error(msg,*args,**kvargs):
    msg = msg%(args)
    print >>sys.stderr,format%{"asctime":datetime.datetime.today(),"levelname":"ERROR","message":msg}


def critical(msg,*args,**kvargs):
    msg = msg%(args)
    print >>sys.stderr,format%{"asctime":datetime.datetime.today(),"levelname":"CRITICAL","message":msg}

def print_log(msg):
    print >>sys.stderr,msg
    



def main():
    debug('debug message')
    info('info message')
    warning('warn message %s',"args test")
    error('error message')
    critical('critical message')
    pass


if __name__ == "__main__":
    main()
